Skip to main content

arguments object

In functions, there are values that are passed in called arguments.

  • The arguments are passed into parameters.

Hence, one can think of arguments as realized parameters through function calls.

The arguments object contains all arguments in an Array format. Thus, Array methods can be utilized.

Here is an example:

info

One can find the size or amount of arguments via arguments.length

  • An important fact and example is the argument objects can be variable in size.

    • That is, the function is defined so the user can enter 0, 1 or 2+ variables.

Here is an example, and how to implement a function for such a case:

info

arguments[] start at index 0 like an Array.

Also, ...params is how you create a variable amount of arguments: this will be covered in the chapter "Parameters".

Another example is changing an argument: